Shiny App - Hogwarts Published on shinyapps.io https://zina-kurian.shinyapps.io/hogwartsapp/
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Hogwarts Sorting"),
sidebarPanel(
h3('Which Hogwarts house should you be in?'),
textInput(inputId="text1", label = "What is your favorite color?"),
actionButton("goButton","go")
),
mainPanel(
h3('Results of sorting...'),
p('Your color is..'), textOutput('otext1'),
p("Hmm what house do you think you are? "), textOutput('oresult')
)
))
Your color is..
Hmm what house do you think you are?
##
shinyServer(
function(input, output) {
output$otext1 = renderPrint({input$text1})
text_reactive <- eventReactive( input$goButton, {
if (input$text1 == "green") " You're Slytherin"
else if (input$text1== "purple") " You're Ravenclaw"
else if (input$text1 == "blue") "You're Hufflepuff"
else if (input$text1 == "gold") "You're Gryffindor"
else "Pick a different color...blue,gold,purple,green"
})
output$oresult = renderPrint({
text_reactive()
})
})
##
runApp(‘~/Documents/JHU Grad School/DS4BME/HW4/project/hogwartsapp’, display.mode=“showcase”)
Recreate plots as ploty interactive, and host them
#library(ggplot2)
datnew = read.table("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/classInterests.txt", header=TRUE)
m = ggplot(datnew,aes(x=Year))
m = m + geom_bar()
k = ggplot(datnew,aes(x=Program))
k = k + geom_bar()
ggplotly(k)
library(ggmosaic)
j = ggplot(data = datnew, mapping = aes(x=Program,y=Year))
j = j + geom_mosaic(aes(x=product(Year,Program), fill=Year))
ggplotly(j)
headers3 = read.csv("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/healthcare.csv", skip = 1, header = F, nrows = 1, as.is = T)
df3 = read.csv("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/healthcare.csv", header = F)
colnames(df3)= headers3
tempDF <- df3
tempDF[] <- lapply(df3, as.character)
colnames(df3) <- tempDF[1, ]
df3 <- df3[-1 ,]
tempDF <- NULL
#make the third row the headers
names(df3) <- as.matrix(df3[1, ])
df3 <- df3[-1, ]
df3[] <- lapply(df3, function(x) type.convert(as.character(x)))
#do it again
names(df3) <- as.matrix(df3[1, ])
df3 <- df3[-1, ]
df3[] <- lapply(df3, function(x) type.convert(as.character(x)))
#
#healthtibble <- tibble(df)
longerdf3 <- pivot_longer(df3,cols = -Location, names_to="year",values_to="value")
#Make long format
#remove the beginning and end
#make first row the column headers
#group by Location
longerdf3 = longerdf3[1:1248,]
h = ggplot(longerdf3,aes(x=year,y=value,group=Location,color=Location)) + geom_line()
h = h + theme(axis.text.x = element_text(angle = 90))
h = h + theme(axis.text.y = element_text(angle = 75))
ggplotly(h)
#df = read.csv("healthcare.csv", header = F)
#put the long dataframe from problem 5 into a pivot longer
#longerdf10 %>% pivot_longer(df3)
longerdf10 = longerdf3
longerdf11 <- longerdf10 %>% mutate(value=as.double(value))
meanlongerdf11 <- longerdf11 %>% group_by(Location) %>% mutate(Meanspend = mean(value))
meanplot = ggplot(meanlongerdf11,color=Location) + geom_bar(aes(x=Location,y=Meanspend),stat="identity")
meanplot = meanplot + theme(axis.text.x = element_text(angle = 80,hjust=1))
ggplotly(meanplot)
Shiny App - BMI Link to hosted app
dat = readSubjectDf("kirb21.txt")
dat = select(dat, -rawid)
df3 <- dat %>% group_by(type, level) %>% summarise_at(vars(volume),mean)
d10 = ggplot(df3,aes(x=type))
d10 = d10 + geom_bar()
d10
d10 = ggplot(df3,color= level) + geom_bar(aes(x= type,y=volume, group = level) ,stat="identity")
m = leaflet() %>%
addTiles() %>%
addMarkers(lat=39.302132, lng=-76.615517, popup="Zina's favorite place")
m